import superStyle from './style.js'

let attrs = {
  'attr': '',
  'direction': 'flex-direction',
  'width': 'width',
  'height': 'height',
  'lineHeight': 'line-height',
  'position': 'position',
  'display': 'display',
  'alignItem': 'align-items',
  'jc': 'justify-content',
  'bgColor': 'background-color',
  'bgImage': 'background-Image',
  'bg': 'background',
  'flex': 'flex',
  'border': 'border',
  'zIndex': 'z-index',
  'radius': 'border-radius',
  'circle': 'border-radius',
  'margin': 'margin',
  'padding': 'padding',
  'mt': 'margin-top',
  'mb': 'margin-bottom',
  'ml': 'margin-left',
  'mr': 'margin-right',
  'pt': 'padding-top',
  'pb': 'padding-bottom',
  'pl': 'padding-left',
  'pr': 'padding-right',
  'bt': 'border-top',
  'bb': 'border-bottom',
  'bl': 'border-left',
  'br': 'border-right',
  'top': 'top',
  'bottom': 'bottom',
  'left': 'left',
  'right': 'right',
  'overflow': 'overflow',
  'maxHeight': 'max-height',
  'maxWidth': 'max-width',
  'visibility': 'visibility',
}
export default {
  props: {
    //方便线上 其他的属性
    attrs: String,
    width: String,
    maxWidth: String,
    maxHeight: String,
    lineHeight: String,
    height: String,
    position: String,
    display: String,
    bgColor: String,
    bgImage: String,
    bg: String,
    // 是否 为圆
    circle: Boolean,
    //圆角 数组[left-top|right-top|left-bottom|right-bottom]
    //四个角
    radius: String,
    //描边
    border: String,
    bt: String,
    bb: String,
    bl: String,
    br: String,
    margin: String,
    mt: String,
    mb: String,
    ml: String,
    mr: String,
    padding: String,
    pt: String,
    pb: String,
    pl: String,
    pr: String,
    top: String,
    bottom: String,
    left: String,
    right: String,
    zIndex: String,
    //flex 布局属性
    direction: String,
    alignItem: String,
    flex: String,
    jc: String,
    visibility: String,
    visible: {
      type: Boolean,
      default: true
    }
  },
  getStyle: (data, call) => {
    return superStyle.getStyle(data, (val, attrName) => {
      //在线配置属性
      if ('attrs' === attrName) {
        return ''
      }
      if (attrs[attrName]) {
        if ('circle' === attrName) {
          if (val === true || val === 'true') {
            val = '50% !important;'
          } else {
            val = ''
          }
        }
        attrName = attrs[attrName]
      } else {
        //没有注册的属性 判断 是否有值
        return val ? val : ''
      }
      return call ? call(val, attrName) : {
        attrName,
        val
      }
    })
  },
  addAttr: (attrName, attrValue) => {
    attrs[attrName] = attrValue
  }
}

